import Vue from 'vue'
import Router from 'vue-router'
import { path } from 'chromedriver'

Vue.use(Router)
const router = new Router({
  routes: [
    {
      path: '/',
      redirect: '/home'

    },
    {
      // 首页
      path: '/home',
      name: 'home',
      component: resolve => (require(["../views/home/home"], resolve)),

    },
    {
      // 一级分类
      path: '/aClassify',
      name: 'aClassify',
      component: resolve => (require(["../views/aClassity/aClassify"], resolve))
    },
    {
      // 搜索
      path: '/search',
      name: 'search',
      component: resolve => (require(["../views/search/search"], resolve))
    },
    {
      // 商品列表
      path: '/shoppingList',
      name: 'shoppingList',
      component: resolve => (require(["../views/shoppingList/shoppingList"], resolve))
    },
    {
      // 团购
      path: '/groupbuying',
      name: 'groupbuying',
      component: resolve => (require(["../views/groupbuying/groupbuying"], resolve))
    },
    {
      // 低价促销
      path: '/lowPrice',
      name: 'lowPrice',
      component: resolve => (require(["../views/lowPrice/lowPrice"], resolve))
    },
    {
      // 在线拍卖
      path: '/onlineAuction',
      name: 'onlineAuction',
      component: resolve => (require(["../views/onlineAuction/onlineAuction"], resolve))
    },
    {
      // 在线竞拍
      path: '/purchase',
      name: 'purchase',
      component: resolve => (require(["../views/purchase/purchase"], resolve))
    },
    {
      // 录入招标信息
      path: '/spgentering',
      name: 'spgentering',
      component: resolve => (require(["../views/spgentering/spgentering"], resolve))
    },
    {
    // 选品库
      path: '/select',
      name: 'select',
      component: resolve => (require(["../views/select/select"], resolve))
    },
    // 供应商
    {
      path: '/supplier',
      name: 'supplier',
      component: resolve => (require(["../views/supplier/supplier"], resolve))
    },
    // 商品详情
    {
      path: '/goodsDetail',
      name: 'goodsDetail',
      component: resolve => (require(["../views/goodsDetail/goodsDetail"], resolve))
    },
    // 购物车
    {
      path: '/shopCart',
      name: 'shopCart',
      component: resolve => (require(["../views/shopCart/shopCart"], resolve))
    },
    // 个人中心
    {
      path: '/my',
      name: 'my',
      component: resolve => (require(["../views/my/my"], resolve))
    },
    // 地址管理
    {
      path: '/site',
      name: 'site',
      component: resolve => (require(["../views/site/site"], resolve))
    },
    // 添加地址
    {
      path: '/addsite',
      name: 'addsite',
      component: resolve => (require(["../views/addsite/addsite"], resolve))
    },
    // 接单
    {
      path: '/orderReceiving',
      name: 'orderReceiving',
      component: resolve => (require(["../views/orderReceiving/orderReceiving"], resolve))
    },
    // 订单管理
    {
      path: '/orders',
      name: 'orders',
      component: resolve => (require(["../views/orders/orders"], resolve))
    },
    // 退款
    {
      path: '/refundMoeny',
      name: 'refundMoeny',
      component: resolve => (require(["../views/orders/refundMoeny"], resolve))
    },
    // 待取件
    {
      path: '/takesGoods',
      name: 'takesGoods',
      component: resolve => (require(["../views/takesGoods/takesGoods"], resolve))
    },
    // 找物流
    {
      path: '/logisticsQuery',
      name: 'logisticsQuery',
      component: resolve => (require(["../views/logisticsQuery/logisticsQuery"], resolve))
    },
    // 已取件
    {
      path: '/haveTake',
      name: 'haveTake',
      component: resolve => (require(["../views/haveTake/haveTake"], resolve))
    },
    // 运输中
    {
      path: '/intransit',
      name: 'intransit',
      component: resolve => (require(["../views/intransit/intransit"], resolve))
    },
    // 已签收
    {
      path: '/received',
      name: 'received',
      component: resolve => (require(["../views/received/received"], resolve))
    },
    // 指派司机
    {
      path: '/assignDriver',
      name: 'assignDriver',
      component: resolve => (require(["../views/assignDriver/assignDriver"], resolve))
    },
    // 路线列表
    {
      path: '/lineList',
      name: 'lineList',
      component: resolve => (require(["../views/lineList/lineList"], resolve))
    },
    // 添加路线
    {
      path: '/addLine',
      name: 'addLine',
      component: resolve => (require(["../views/addLine/addLine"], resolve))
    },
    // 司机列表
    {
      path: '/driverList',
      name: 'driverList',
      component: resolve => (require(["../views/driverList/driverList"], resolve))
    },
    // 申请售后
    {
      path: '/afterSalesOrder',
      name: 'afterSalesOrder',
      component: resolve => (require(["../views/orders/afterSalesOrder"], resolve))
    },
    // 竞标管理
    {
      path: '/competeManage',
      name: 'competeManage',
      component: resolve => (require(["../views/competeManage/competeManage"], resolve))
    },
    // 竞标报价
    {
      path: '/competeManageDetail',
      name: 'competeManageDetail',
      component: resolve => (require(["../views/competeManage/competeManageDetail"], resolve))
    },
    // 商品管理
    {
      path: '/goodsManage',
      name: 'goodsManage',
      component: resolve => (require(["../views/goodsManage/goodsManage"], resolve))
    },
    // 全部物流信息
    {
      path: '/allOrders',
      name: 'allOrders',
      component: resolve => (require(["../views/allOrders/allOrders"], resolve))
    },
    // 商家入驻
    {
      path: '/shopJoin',
      name: 'shopJoin',
      component: resolve => (require(["../views/shopJoin/shopJoin"], resolve))
    },
    // 供应商入驻
    {
      path: '/supplierJoin',
      name: 'supplierJoin',
      component: resolve => (require(["../views/supplierJoin/supplierJoin"], resolve))
    },
    // 支付成功
    {
      path: '/paySuccess',
      name: 'paySuccess',
      component: resolve => (require(["../views/statusPages/paySuccess"], resolve))
    },
    // 支付异常
    {
      path: '/payUnusual',
      name: 'payUnusual',
      component: resolve => (require(["../views/statusPages/payUnusual"], resolve))
    },
    // 等待审核
    {
      path: '/payWait',
      name: 'payWait',
      component: resolve => (require(["../views/statusPages/payWait"], resolve))
    },
    // 支付失败
    {
      path: '/payBreak',
      name: 'payBreak',
      component: resolve => (require(["../views/statusPages/payBreak"], resolve))
    },
    // 查看报价
    {
      path: '/bidQuotation',
      name: 'bidQuotation',
      component: resolve => (require(["../views/bidQuotation/bidQuotation"], resolve))
    },
    // 优惠券
    {
      path: "/discount",
      name: 'discount',
      component: resolve => (require(["../views/discount/discount"], resolve))
    },
    // 选择优惠券
    {
      path: "/selectDiscount",
      name: 'selectDiscount',
      component: resolve => (require(["../views/discount/selectDiscount"], resolve))
    },
    // 认证商家
    {
      path: "/provider",
      name: "provider",
      component: resolve => (require(["../views/provider/provider"], resolve))
    },
    // 基地
    {
      path: "/base",
      name: "base",
      component: resolve => (require(["../views/provider/base"], resolve))
    },
    // 竞标报价
    {
      path: "/transaction",
      name: "transaction",
      component: resolve => (require(["../views/transaction/transaction"], resolve))
    },
    // 店铺首页
    {
      path: "/shopHome",
      name: "shopHome",
      component: resolve => (require(["../views/shopHome/shopHome"], resolve))
    },
    // 咨询详情
    {
      path: "/advisory",
      name: "advisory",
      component: resolve => (require(["../views/advisory/advisory"], resolve))
    },

    // 供应商入驻表单
    {
      path: '/authForm',
      name: 'authForm',
      component: resolve => (require(["../views/shopJoin/authForm"], resolve))
    },
    // 第二步
    {
      path: '/authForm2',
      name: 'authForm2',
      component: resolve => (require(["../views/shopJoin/authForm2"], resolve))
    },
    // 第三步
    {
      path: '/authForm3',
      name: 'authForm3',
      component: resolve => (require(["../views/supplierJoin/authForm3"], resolve))
    },
    // 选择主营
    {
      path: '/mainBusiness',
      name: 'mainBusiness',
      component: resolve => (require(["../views/shopJoin/mainBusiness"], resolve))
    },
    // 选择主营
    {
      path: '/twoClassify',
      name: 'twoClassify',
      component: resolve => (require(["../views/aClassity/twoClassify"], resolve))
    },
  ],
  scrollBehavior (to, from, savedPosition) {
    return { x: 0, y: 0 }
  }
})

router.beforeEach((to, from, next) => {
  if (to.query && to.query.token) {
    localStorage.setItem('token', to.query.token)
  }
  return next(
    
  )
})


export default router
